﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iTextSharp;
using iTextSharp.text;
using iTextSharp.text.pdf;

namespace Gollie.Pdf
{
	public class PdfCell : PdfPCell
	{
		PdfCellProperties properties = PdfCellProperties.defaultProperties;

		public PdfCell()
			: this(null, null)
		{
		}

		public PdfCell(PdfCellProperties properties)
			: this(null, properties)
		{
		}

		public PdfCell(string text)
			: this(text, null)
		{
		}

		public PdfCell(string text, PdfCellProperties properties)
			: base()
		{
			if (properties != null)
				this.properties = properties;

			this.SetProperties();

			if (text != null)
				this.Text = text;
		}

		public string Text
		{
			get
			{
				return this.Phrase.ToString();
			}
			set
			{
				this.Phrase = new Phrase(value, properties.Font);
			}
		}

		public void SetProperties(PdfCellProperties properties)
		{
			this.properties = properties;

			this.SetProperties();
		}

		private void SetProperties()
		{
			this.Border = properties.Border;
			this.BorderColor = properties.BorderColor;
			this.BorderColorBottom = properties.BorderColorBottom;
			this.BorderColorLeft = properties.BorderColorLeft;
			this.BorderColorRight = properties.BorderColorRight;
			this.BorderColorTop = properties.BorderColorTop;
			this.BorderWidth = properties.BorderWidth;
			this.BorderWidthBottom = properties.BorderWidthBottom;
			this.BorderWidthLeft = properties.BorderWidthLeft;
			this.BorderWidthRight = properties.BorderWidthRight;
			this.BorderWidthTop = properties.BorderWidthTop;
			this.Padding = properties.Padding;
			this.PaddingBottom = properties.PaddingBottom;
			this.PaddingLeft = properties.PaddingLeft;
			this.PaddingRight = properties.PaddingRight;
			this.PaddingTop = properties.PaddingTop;
			this.VerticalAlignment = properties.VerticalAlignment;
			this.HorizontalAlignment = properties.HorizontalAlignment;
			this.Text = properties.Text;
			this.Colspan = properties.Colspan;
		}

	}
}
